added Feb 2001 SDK
[windows-sources.git] / shared source / sscli20 / jscript / engine / enumeratorconstructor.cs
blob8c5d4c11a822aaca8bd1e9d26dd1666b95722b7d
1 // ==++==
2 //
3 //
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
5 //
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
10 //
11 // You must not remove this notice, or any other, from this software.
12 //
13 //
14 // ==--==
16 namespace Microsoft.JScript {
18 using System;
19 using System.Collections;
20 using System.Diagnostics;
21 using System.Reflection;
23 public sealed class EnumeratorConstructor : ScriptFunction{
24 internal static readonly EnumeratorConstructor ob = new EnumeratorConstructor();
26 private EnumeratorPrototype originalPrototype;
28 internal EnumeratorConstructor()
29 : base(FunctionPrototype.ob, "Enumerator", 1) {
30 this.originalPrototype = EnumeratorPrototype.ob;
31 EnumeratorPrototype._constructor = this;
32 this.proto = EnumeratorPrototype.ob;
35 internal EnumeratorConstructor(LenientFunctionPrototype parent, LenientEnumeratorPrototype prototypeProp)
36 : base(parent, "Enumerator", 1) {
37 this.originalPrototype = prototypeProp;
38 prototypeProp.constructor = this;
39 this.proto = prototypeProp;
40 this.noExpando = false;
43 internal override Object Call(Object[] args, Object thisob){
44 return null;
47 internal override Object Construct(Object[] args){
48 return this.CreateInstance(args);
51 [JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
52 public new EnumeratorObject CreateInstance(params Object[] args){
53 if (args.Length != 0){
54 Object obj = args[0];
55 if (obj is IEnumerable)
56 return new EnumeratorObject(this.originalPrototype, (IEnumerable)obj);
57 throw new JScriptException(JSError.NotCollection);
58 }else
59 return new EnumeratorObject(this.originalPrototype, (IEnumerable)null);
62 public Object Invoke(){
63 return null;